#include<stdio.h>


/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
 void Sewap(int* a, int i, int j){
    int tmp = a[i];
    a[i] = a[j];
    a[j] = tmp;
 }
int* shuffle(int* nums, int numsSize, int n){
    // *returnSize = numsSize;
    // int* a = (int*)malloc(sizeof(int) * numsSize);
    // for(int i = 0, j = n, k = 0; i <n; i++, j++){
    //     a[k] = nums[i];
    //     k++;
    //     a[k]= nums[j];
    //     k++;
    // }
    // return a;

    Sewap(nums, n, n - 1);
    int i = n - 1, j = n;
    while(i > 1 && j < numsSize - 1){
        Sewap(nums, i, i - 1);
        Sewap(nums, j, j + 1);
        i--; j++;
    }
    return nums;
}

int main1(){
    int nums[] = {2,5,1,3,4,7};
    int sz = 6;
    int* a = shuffle(nums, sz, sz / 2);

    for(int i = 0; i < sz; i++){
        printf("%d ", nums[i]);
    }
    return 0;
}